#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<unistd.h>
#include<errno.h>

char *newenv =(char*) "myVAL = 666666";

int main(){
  printf("我的程序要开始运行了！\n");
  if(fork() == 0)
  {
      printf("I am Child, MY Pid Is : %d\n", getpid());
      //execl("/usr/bin/ls","/usr/bin/ls", "-ln" NULL);
      
     // execlp("ls","ls", "-ln", NULL);
      sleep(1);
     // char* const argv[] = {(char* const)"ls",(char* const) "-l", NULL};
     // execv("/usr/bin/ls", argv);
     // execvp(argv[0], argv);
      char *const argv[] = {
        (char* const)"other",
        (char* const)"-a",
        (char* const)"-b",
        (char* const)"-c",
        (char* const)"-d",
        NULL
      };
      char *const env[] = {
        (char* const) "MYVAL = 123456789",
        NULL
      };
      for(int i = 0; env[i]; i++){
        putenv(env[i]);
      }
      extern char** environ;
      //putenv(newenv);
      execvpe("./other", argv, environ);
      exit(1);
  }
  waitpid(-1, NULL, 0);
  printf("我的程序运行完成了\n");
  exit(1);

}
